package per.xue.carid_booking.dto;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.beanutils.PropertyUtils;
import org.springframework.format.annotation.DateTimeFormat;
import per.xue.carid_booking.entity.Car;

import java.lang.reflect.InvocationTargetException;
import java.util.Date;

/**
 * @auther zhang
 * @ TO DO
 * @creatTime 2021/5/23 20:57
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class CarMapperDTO {

    /**
     * 车次id
     */
    private String carId;

    /**
     * 发车时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date time;

    /**
     * 初始站id
     */
    private Integer startStationId;


    /**
     * 终点站id
     */
    private Integer endStationId;


    /**
     * 价格
     */
    private Double price;

    /**
     * 剩余量
     */
    private Integer surplusNum;

    /**
     * 状态
     */
    private String stats;


    /**
     * 发车时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date startTime;


    /**
     * 到站时间
     */
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    private Date endTime;

    public CarMapperDTO(Car car,Date startTime,Date endTime) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        PropertyUtils.copyProperties(this, car);
        this.startTime = startTime;
        this.endTime = endTime;
    }
}
